package hv.lib.text {
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	/**
	 * @author hvong
	 */
	public class Text extends TextField
	{
		public static var css:StyleSheet = new StyleSheet();
		
		/*
		 * Creates a new textfield with stylesheet and default values
		 * @param : set a default text to the textfield
		 */
		public function Text(label:String = "") 
		{
			styleSheet = css;
			mouseEnabled = false;
			autoSize = TextFieldAutoSize.LEFT;
			multiline = true;
			htmlText = label;
			antiAliasType = AntiAliasType.ADVANCED;
			embedFonts = true;
		}
		
		/*
		 * Traces all fonts available in flash, they can be shared fonts or embeded in textfield
		 * Use the traced fontName for the font-family value in your stylesheet file (.css)
		 */
		public static function traceAvailableFonts():void {
			var fonts:Array = Font.enumerateFonts(true);
			var font:Font;
			var l:int = fonts.length;
			if (l>0) {
				for (var i:int = 0; i < l; i++ ) {
					font = fonts[i];
					trace("-- " +font.fontName, "("+font.fontStyle+")");
				}
			} else {
				trace("-- 0 fonts embedded");
			}
		}
	}
}